const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const GoodsSchema = new mongoose.Schema({
  //形状
  shape: {
    type: String,
    required: [true, "you must tell us good shape"],
  },
  // 图片
  image: {
    type: Array,
    required: true,
  },
  //基板
  baseplate: {
    type: Schema.Types.ObjectId,
    ref: "CompanyMaterial",
    required: [true, "you must tell us your baseplate"],
  },
  //基板加工费
  b_process: {
    price: {
      type: Number,
      required: [true, "you must tell us your baseplate processing cost"],
      min: 0,
    },
    processMode: {
      type: String,
      enum: ["0", "1"],
      required: [true, "you must tell us your baseplate processingMode"],
    }, //0表示按重量计算 1表示按面积计算  元/kg  元/m2
  },

  //覆板
  shroudplate: {
    type: Schema.Types.ObjectId,
    ref: "CompanyMaterial",
    required: [true, "you must tell us your shroudplate"],
  },
  //覆板加工费
  s_process: {
    price: {
      type: Number,
      required: [true, "you must tell us your shroudplate processing cost"],
      min: 0,
    },
    processMode: {
      type: String,
      enum: ["0", "1"],
      required: [true, "you must tell us your shroudplate processing cost"],
    }, //0表示按重量计算 1表示按面积计算
  },
  companyId: {
    type: Schema.Types.ObjectId,
    ref: "Company",
    required: [true, "you must tell us your comanyId of goods "],
  },
  title: {
    type: String,
    required: [true, "you must tell us title"],
  },
});

const Goods = mongoose.model("Goods", GoodsSchema);
module.exports = Goods;
